package com.example.demo.zabbix.request.builder.configuration;

import com.example.demo.zabbix.request.BaseRequest;
import com.example.demo.zabbix.request.builder.request.RequestBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * https://www.zabbix.com/documentation/4.0/manual/api/reference/configuration/import
 */
public class ConfigurationImportRequestBuilder extends RequestBuilder<Map<String,Object>> {
    public enum FORMAT{json,xml}
    private FORMAT format;
    private String source;
    private Map<String,Object> rules;

    public ConfigurationImportRequestBuilder(String auth) {
        super("configuration.import", auth);
        baseRequest.setParams(new HashMap<>());
    }

    public ConfigurationImportRequestBuilder( Long id, String auth) {
        super("configuration.import", id, auth);
        baseRequest.setParams(new HashMap<>());
    }

    public ConfigurationImportRequestBuilder setParam(String key, Object value){
        baseRequest.getParams().put(key,value);
        return this;
    }
    public ConfigurationImportRequestBuilder setParams(Map<String,Object> params){
        baseRequest.getParams().putAll(params);
        return this;
    }

    public FORMAT getFormat() {
        return format;
    }

    public ConfigurationImportRequestBuilder setFormat(FORMAT format) {
        this.format = format;
        return this;
    }

    public String getSource() {
        return source;
    }

    public ConfigurationImportRequestBuilder setSource(String source) {
        this.source = source;
        return this;
    }

    public Map<String, Object> getRules() {
        return rules;
    }

    public ConfigurationImportRequestBuilder setRules(Map<String, Object> rules) {
        this.rules = rules;
        return this;
    }

    @Override
    public BaseRequest<Map<String,Object>> builder() {
        baseRequest.getParams().put("format",format.name());
        baseRequest.getParams().put("source",source);
        baseRequest.getParams().put("rules",rules);
        return baseRequest;
    }
}
